-use auto::Repo;
+use auto::{Repo, RepoListRefsExtFlags};
use ffi;
use gio;
use glib;
use glib::IsA;
use glib::translate::*;
use glib_ffi;
-use std::collections::HashSet;
+use std::collections::{HashSet, HashMap};
use std::ptr;
use std::path::Path;
use ObjectName;
&self,
commit_checksum: &str,
maxdepth: i32,
- cancellable: P) -> Result<HashSet<ObjectName>, Error>;
+ cancellable: P
+ ) -> Result<HashSet<ObjectName>, Error>;
+ fn list_refs<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b gio::Cancellable>>>(
+ &self,
+ refspec_prefix: P,
+ cancellable: Q
+ ) -> Result<HashMap<String, String>, Error>;
+ fn list_refs_ext<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b gio::Cancellable>>>(
+ &self,
+ refspec_prefix: P,
+ flags: RepoListRefsExtFlags,
+ cancellable: Q
+ ) -> Result<HashMap<String, String>, Error>;
}
impl<O: IsA<Repo> + IsA<glib::Object> + Clone + 'static> RepoExtManual for O {
cancellable.into().to_glib_none().0,
&mut error,
);
- if error.is_null() { Ok(from_glib_container_variant_set(hashtable)) } else { Err(from_glib_full(error)) }
+ if error.is_null() {
+ Ok(from_glib_container_variant_set(hashtable))
+ } else {
+ Err(from_glib_full(error))
+ }
+ }
+ }
+
+ fn list_refs<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b gio::Cancellable>>>(
+ &self,
+ refspec_prefix: P,
+ cancellable: Q
+ ) -> Result<HashMap<String, String>, Error> {
+ unsafe {
+ let mut error = ptr::null_mut();
+ let mut hashtable = ptr::null_mut();
+ let _ = ffi::ostree_repo_list_refs(
+ self.to_glib_none().0,
+ refspec_prefix.into().to_glib_none().0,
+ &mut hashtable,
+ cancellable.into().to_glib_none().0,
+ &mut error,
+ );
+
+ if error.is_null() {
+ Ok(FromGlibPtrContainer::from_glib_container(hashtable))
+ } else {
+ Err(from_glib_full(error))
+ }
+ }
+ }
+
+ fn list_refs_ext<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b gio::Cancellable>>>(
+ &self,
+ refspec_prefix: P,
+ flags: RepoListRefsExtFlags,
+ cancellable: Q
+ ) -> Result<HashMap<String, String>, Error> {
+ unsafe {
+ let mut error = ptr::null_mut();
+ let mut hashtable = ptr::null_mut();
+ let _ = ffi::ostree_repo_list_refs_ext(
+ self.to_glib_none().0,
+ refspec_prefix.into().to_glib_none().0,
+ &mut hashtable,
+ flags.to_glib(),
+ cancellable.into().to_glib_none().0,
+ &mut error,
+ );
+
+ if error.is_null() {
+ Ok(FromGlibPtrContainer::from_glib_container(hashtable))
+ } else {
+ Err(from_glib_full(error))
+ }
}
}
}
fn main() {
let repo = libostree::Repo::new_for_path("../../../repo-bare");
- //let result = repo.create(libostree::RepoMode::Archive, Option::None);
- //result.expect("we did not expect this to fail :O");
-
repo.open(None).expect("should have opened");
+ let refs = repo.list_refs(None, None).unwrap();
+ for (refspec, checksum) in refs {
+ println!(" {} = {}", refspec, checksum);
+ }
+
let (file, checksum) = repo.read_commit("test", None).unwrap();
println!("path: {:?}", file.get_path());